/**
 * @file yolov5Lib.cpp
 * @author hongjian.huang (hongjian.huang@lynxi.com)
 * @brief
 * @version 0.1
 * @date 2022-08-26
 *
 * Copyright:
 * © 2018 北京灵汐科技有限公司 版权所有。
 * 注意：以下内容均为北京灵汐科技有限公司原创，未经本公司允许，不得转载，否则将视为侵权；对于不遵守此声明或者其他违法使用以下内容者，本公司依法保留追究权。
 * © 2018 Lynxi Technologies Co., Ltd. All rights reserved.
 * NOTICE: All information contained here is, and remains the property of Lynxi. This file can not
 * be copied or distributed without the permission of Lynxi Technologies Co., Ltd.
 *
 * @par 修改日志:
 * Data:2022-08-26
 * Author: hongjian.huang
 * Description:
 */

#include "lenetLib.h"

#include <sys/time.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <lyn_plugin_dev.h>
#include <string>
#include <utility>
#include <vector>

int lynLenetProcess(LenetPostInfo *para)
{
    uint16_t *ptr = (uint16_t *) lynPluginGetVirtAddr(para->apuOut);
    unsigned char *imgData = (unsigned char *) lynPluginGetVirtAddr(para->imgData);
    size_t n = para->apuOutSize / 2;
    int idx = 0;
    for (size_t i = 0; i < n; i++) {
        idx = (ptr[idx] < ptr[i]) ? i : idx;
    }
    lynDrawTextAttr textAttr;
    textAttr.imgData = imgData;
    textAttr.imgH = para->imgDataH;
    textAttr.imgW = para->imgDataW;
    textAttr.imgFmt = para->imgFmt;
    textAttr.fontSize = FONT_SIZE_64;
    textAttr.startX = 20;
    textAttr.startY = 100;
    std::string res = std::to_string(idx);
    textAttr.text = const_cast<char*>(res.c_str());
    lynPluginDrawText(&textAttr);
    return 0;
}
